<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:60:"C:\wamp200\www\xgwnew/application/index\view\cart\frank.html";i:1536152846;s:61:"C:\wamp200\www\xgwnew/application/index\view\public\base.html";i:1536844932;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="__PUBLIC__/xsd/css/mui.min.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/icons-extra.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/app.css?v1111121" />

</head>
<!--/head-->
<body>


	<!--/header-->

<style>
    .mui-row.mui-fullscreen>[class*="mui-col-"] {
        height: 100%;
    }

    .mui-col-xs-3,
    .mui-col-xs-9 {
        overflow-y: auto;
        height: 100%;
    }

    .mui-segmented-control .mui-control-item {
        line-height: 50px;
        width: 100%;
    }

    .mui-control-content {
        display: block;
    }

    .mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active {
        background-color: #fff;
    }
    .mui-toast-container {
        bottom: 50%;
        z-index: 999999999999999999;
    }
    .mui-btn-block{
      padding: 5px;
      border: 1px solid #ccc !important;
      margin: 5px;
      -webkit-appearance: none;
    }
    .active .mui-icon{
      display: block !important;
    }
    .submitbuttonqx {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 2.876712rem;
        background-color: red;
        color: #fff;
        text-align: center;
        text-decoration: none;
        font-size: 0.410959rem;
        font-weight: bold;
        line-height: 1.315068rem;
    }
</style>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/checkout.css" />
<header class="mui-bar mui-bar-nav" style="z-index:7">
			<a class="mui-icon mui-icon-left-nav mui-pull-left" href="<?php echo url('index/index/frank'); ?>"></a>
			<h1 class="mui-title">确定订单</h1>
</header>
<div class="mui-content" style="    margin-bottom:60px;">
  <div  class="checkout-section" >
      <section class="cart-address" >
          <div class="address-item"   onclick='window.location.href = "<?php echo url('index/address/index'); ?>"'   <?php if(empty($address['sex']) || ($address['sex'] instanceof \think\Collection && $address['sex']->isEmpty())): ?>style="display: none;"<?php endif; ?>>
              <h2 class="address-name" > <b ><?php echo $address['name']; ?></b> <span ><?php if($address['sex'] == '1'): ?>先生<?php else: ?>女士<?php endif; ?></span> <span ><?php echo $address['tel']; ?></span> </h2>
              <p class="address-detail" ><?php echo $address['address']; ?>-<?php echo $address['house_number']; ?></p> <span class="mui-icon mui-icon-arrowright"></span>  </div>
          <div class="address-item" onclick='window.location.href = "<?php echo url('index/address/add'); ?>"' <?php if(!(empty($address['sex']) || ($address['sex'] instanceof \think\Collection && $address['sex']->isEmpty()))): ?>style="display: none;"<?php endif; ?> > 请添加一个收货地址 <span class="mui-icon mui-icon-arrowright"></span> </div>
      </section>

  <br />
  <section class="cart-group checkout-section">
      <ul class="foodlist" style="    margin: 0;">
          <?php if(is_array($cartinfo['list']) || $cartinfo['list'] instanceof \think\Collection): $i = 0; $__LIST__ = $cartinfo['list'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
            <li> <span class="cellname"><?php echo $vo['good_name']; ?></span> <span class="cellquantity">x&nbsp;<?php echo $vo['num']; ?></span> <span class="celltotal">¥<?php echo $vo['num']*$vo['good_price']; ?></span> </li>
          <?php endforeach; endif; else: echo "" ;endif; if(empty($cartinfo['list']) || ($cartinfo['list'] instanceof \think\Collection && $cartinfo['list']->isEmpty())): ?>
            <script>
              window.location.href = "<?php echo url('index/index/index'); ?>"
            </script>
          <?php endif; ?>
      </ul>
    <div class="fee" >
        <div>运费</div>
        <div id="freight" >¥0.00</div>
    </div>


      <div class="total">
          <div> <span>总计 <span id="zj">¥<?php echo $cartCountprice+$address['freight']; ?></span>  余额 ¥<?php echo \think\Request::instance()->session('user.balance'); ?></span> &nbsp;&nbsp; </div>
          <span>实付<span style="color:red;" id="sf"></span></span>
        </div>
  </section>



  <section class="checkout-section">
      <div class="cart-item fee" id="payment" style="    margin: 0;">
        <span>支付方式</span>
        <span class="cartitem-right">
          <i id="paywaytext" style="    font-style: normal;">
          <?php if(\think\Cookie::get('pay') == '1'): ?>微信支付<?php else: ?>货到付款<?php endif; ?>
          </i>
          <span class="mui-icon mui-icon-arrowright"></span>
        </span>
      </div>



      <aside class="paylist ">
          <header class="paylist-header">支付方式</header>
          <div class="paylist-item  <?php if(\think\Cookie::get('pay') == '1'): ?>active<?php endif; ?>" data-payway='1' ><span> 微信支付  </span> <span class="mui-icon mui-icon-checkmarkempty" style="color:#007aff;border: 1px solid;display:none"></span></div>
      </aside>
      <div class="mask "></div>


      <a class="cart-item fee"  id="coupon-item" style="    margin: 0;"> <span>优惠券</span>
        <span class="cartitem-right">
          <i style="    font-style: normal;">
            <?php if(empty(\think\Cookie::get('couponlist_id')) || (\think\Cookie::get('couponlist_id') instanceof \think\Collection && \think\Cookie::get('couponlist_id')->isEmpty())): ?>
              请选择优惠券
            <?php else: ?>
              <?php echo get_table_field(\think\Cookie::get('couponlist_id'),"id","price","CouponList"); ?>元优惠券
            <?php endif; ?>
          </i>
          <span class="mui-icon mui-icon-arrowright"></span>
        </span>
      </a>
  </section>




    <form  method="post"  action="<?php echo url('index/order/add'); ?>">
      <section class="checkout-section">
      <div class="mui-input-row" style="margin: 10px 5px;">
      					<textarea id="textarea" name="remark" rows="5" placeholder="备注"></textarea>
      				</div>
      </section>
      <input type="hidden" name="index_type" value="2"  />
      <input type="hidden" name="group_time" value="<?php echo config('grouptime'); ?>"  />
    </form>

  </div>
  <script id="tpl2" type="text/html">
        <div class="select-time-box">
          <style>.wd50{width:50%!important;}</style>

          
                     <dl  class="wd50" id="jtdd"> <dt>{{date1}}<span>{{name1}}</span></dt>
                     	 {{if type1==2}}

                     	<dd class="allow" data-text="{{date1}}10:00-13:00送达" data-val="{{date1}},10:00-13:00">
                           	<label for="radio-choice-0">10:30-13:00</label> </dd>
                           	{{/if}}
                         {{each list as value i}}
                           <dd class="allow" data-text="{{date1}}{{value.start_time}}-{{value.end_time}}送达" data-val="{{date1}},{{value.start_time}}-{{value.end_time}}">
                           	<label for="radio-choice-0">{{value.start_time}}-{{value.end_time}} </label> </dd>
                         {{/each}}
                     </dl>
                     

 
            <dl  class="wd50"> <dt>{{date2}}<span>{{name2}}</span></dt>
            	 {{if type2==2}}

            	<dd class="allow" data-text="{{date2}}10:00-13:00送达" data-val="{{date2}},10:00-13:00">
                  	<label for="radio-choice-0">10:30-13:00</label> </dd>
                  	{{/if}}
                {{each list as value i}}
                  <dd class="allow" data-text="{{date2}}{{value.start_time}}-{{value.end_time}}送达" data-val="{{date2}},{{value.start_time}}-{{value.end_time}}">
                  	<label for="radio-choice-0">{{value.start_time}}-{{value.end_time}} </label> </dd>
                {{/each}}
            </dl>
            
        </div>
  </script>


  <div class="select-time-mask" onclick="hideDeliveryTime()" style="display: none;"></div>
  <div class="select-time-wrap" id="select-model-01" style="display: none;"></div>

  <nav class="mui-bar mui-bar-tab" style="   border-bottom: none;  background-color: #3d3d3f; ">
      <span style="    color: #fff;font-size: .48rem;line-height: 1.273333rem;padding-left: .266667rem;">待支付 <span id="dzf" style="color:red"></span></span>
      <a href="javascript:" class="submitbutton" style="right: 2.876712rem;" >确定下单</a>
      <a  class="submitbuttonqx qxdd" data-url="<?php echo url('index/index/frank'); ?>" >取消订单</a>
  </nav>

</div>




<!--/#footer-->

<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/xsd/js/mui.min.js"></script>
<script src="__PUBLIC__/xsd/js/flexible.js"></script>
<script src="__PUBLIC__/xsd/js/template.js"></script>


  <script type="text/javascript">
    $(function(){

      //初始化送货方式改变价格
      var wayid =  "<?php echo \think\Cookie::get('way'); ?>"
      if(wayid){
        changeprice(wayid)
      }


    //确定下单
    $('.submitbutton').on('tap', function(){

      //window.location.href = "<?php echo url('index/order/add'); ?>"
      $('form').submit()
    })

    $('.qxdd').on('tap', function(){
     var url = $(this).attr('data-url')
     var btnArray = ['否', '是'];
     mui.confirm('您确定要删除该订单吗？', '删除订单', btnArray, function(e) {
       if (e.index == 1) {
           $.post("<?php echo url('index/cart/clear'); ?>", {}, function(data) {
               mui.toast('删除成功！')
               setTimeout(function() {
                 window.location.href= url
               }, 2000);
           }, "json");

       } else {
         return ;
       }
     })
    })


    $('#payment').on('tap', function(){
        $('.paylist').addClass('open');
        $('.paylist').next().addClass('open');
    })
    $('#coupon-item').on('tap', function(){
        window.location.href = "<?php echo url('index/coupon/index'); ?>"
    })
    $('.mask').on('tap', function(){
      $(this).removeClass('open')
      $('.paylist').removeClass('open')
    })
    $('.paylist-item').on('tap', function(){
      var val = $(this).text(),payway = $(this).attr('data-payway')
      $('#paywaytext').text(val)
      $('.paylist').next().removeClass('open')
      $('.paylist').removeClass('open')
      $(this).addClass('active').siblings().removeClass('active')
      $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'pay', 'val': payway}, function(json, textStatus) {});
    })

    })

    $('[name="fhd"]').on('tap', function(){
      var val = $(this).val()
      $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'fhd', 'val': val}, function(json, textStatus) {})
      $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'place_id', 'val': val}, function(json, textStatus) {
        location.reload()
        console.log(111);


      })

      //changeprice(val)

    })
    //自提地点
    $('[name="way"]').on('tap', function(){
      var val = $(this).val()
      $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'way', 'val': val}, function(json, textStatus) {})
      changeprice(val)

    })
    //自提地点
    $.post("<?php echo url('index/address/getArayacak'); ?>", function(data) {
      var html = template('zt', data);
      $('#zt_address').html(html);
    }, "json");

    $(document).on('tap', '#zt_address li', function(){
        var id = $(this).attr('data-ztid')
        $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'zt_address', 'val': id}, function(json, textStatus) {});
    })
    $('#pstime').on('tap', function(){
              $(".select-time-mask").show(), $(".select-time-wrap").show();

    })
      showDeliveryTime()
    function showDeliveryTime() {
        var data = {}
            data.jt = new Date(),
            data.jm = data.jt.getMonth()+1,
            data.jd = data.jt.getDate();
            data.rq = data.jm+'-'+data.jd;
            data.mt = new Date();
            data.mt.setDate(data.mt.getDate()+1);//当前日期+几天
            data.mm = data.mt.getMonth()+1; // 月
            data.md = data.mt.getDate();    // 日
            data.rq2 = data.mm+'-'+data.md;
        $.post("<?php echo url('index/index/getDeliveryTime'); ?>", function(da) {
            if(da){
              data.list = da;

              data.name1 = '今天'
             data.name2 = '明天'
             data.date1 = data.rq+'日'
             data.date2 = data.rq2+'日'

            }

            data.list = [{id: 10, start_time: "13:00", end_time: "18:00", limit_num: 10, type: 0},{id: 11, start_time: "18:00", end_time: "22:00", limit_num: 10, type: 0}]
              // data.name2 = "<?php echo config('grouptime'); ?> 配送"
              var html = template('tpl2', data);
              $('.select-time-wrap').html(html);


              var times = new Date().getHours()+0.1;

              $('#jtdd').find('dd').each(function(){

                //var start = $(this).attr('data-start')
               var start="13:00";
                if(times>= parseInt(start)){
                  $(this).removeClass('allow').addClass('forbidden').removeAttr('onclick').click(function(){
                       mui.toast("亲1，已经过了送货时间，请选择别的时间段~")
                  })
                }
              })




        }, "json");

    }
    $(document).on('tap', '.select-time-box dd.allow',function(){
      var $this = $(this),text = $this.attr('data-text'),val = $this.attr('data-val')
        $('#pssj i').text(text)
        $('#pssj input').val(val)
        $(".select-time-wrap").hide(), $(".select-time-mask").hide()

        $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'deliverytime', 'val': val}, function(json, textStatus) {
   		 });
    })
    function hideDeliveryTime() {
        $(".select-time-mask").hide(), $(".select-time-wrap").hide()
    }

    function changeprice(way_id){
      var cartCountprice = "<?php echo $cartCountprice; ?>", balance = "<?php echo \think\Request::instance()->session('user.balance'); ?>", subsidy = "<?php echo $subsidy; ?>"
      var freight = 0  // way = 2  自提免运费

        $('#zt_address').hide();
      if(way_id == 1){
        freight = "<?php echo (isset($address['freight']) && ($address['freight'] !== '')?$address['freight']:'0'); ?>"

        $('.fbt').text("-¥<?php echo $subsidy; ?>")
      }else if (way_id == 3) {
        //邮寄运费为15
        freight = 15;
      }else if (way_id == 2) {
        $('.fbt').text('-¥0')
          $('#zt_address').show();
      }

      freight = parseFloat(freight)
      cartCountprice = parseFloat(cartCountprice)
      balance = parseFloat(balance)

      //全场满600 免运费
      if(cartCountprice > 600){
        freight = 0
      }

      if(way_id == 1){
        var zj = cartCountprice+freight-subsidy,sf= zj-balance
      }else{
        var zj = cartCountprice+freight,sf= zj-balance
      }






      sf = parseFloat(sf).toFixed(2)

      $('#freight').text("¥"+freight)
      $('#zj').text("¥"+zj);
      $('#sf').text("¥"+sf);
      preferential(sf)



    }
    function  preferential(sf){
      var yhj = "<?php echo get_table_field(\think\Cookie::get('couponlist_id'),"id","price","CouponList"); ?>"
      if(yhj){
        var dzf =sf-parseInt(yhj)
      }else{
        dzf =sf

        yhj = 0
      }

      $('#dzf').text('¥'+dzf)

      if(sf<0){
        var ye = parseFloat("<?php echo \think\Request::instance()->session('user.balance'); ?>")+parseFloat(sf)-parseFloat(yhj)
          ye = ye.toFixed(2)
        $('#sf').text('余额支付'+ye)
        $('#dzf').text('余额支付'+ye)

        $('#paywaytext').text('余额支付')
        $('.paylist').remove();
      }

    }


  </script>

<?php if(!(empty(config('shop_hours')) || (config('shop_hours') instanceof \think\Collection && config('shop_hours')->isEmpty()))): ?>
<script>
  var time_range = function (beginTime, endTime) {
    var strb = beginTime.split (":");
    if (strb.length != 2) {
      return false;
    }

    var stre = endTime.split (":");
    if (stre.length != 2) {
      return false;
    }

    var b = new Date ();
    var e = new Date ();
    var n = new Date ();

    b.setHours (strb[0]);
    b.setMinutes (strb[1]);
    e.setHours (stre[0]);
    e.setMinutes (stre[1]);

    if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
      return true;
    } else {

      mui.alert("<?php echo config('shop_hours_message'); ?>", '公告');
      $('.mui-popup-buttons').html(' ')
      $('.mui-popup-inner').css('border-radius', '13px')
      return false;
    }
  }

  var shop_hours = "<?php echo config('shop_hours'); ?>";
  var hours_arr = shop_hours.split('-');
  time_range (hours_arr[0], hours_arr[1]);

</script>
<?php endif; if(config('is_rest') == '1'): ?>
<script>
mui.alert("<?php echo config('rest_message'); ?>", '公告');
$('.mui-popup-buttons').html(' ')
$('.mui-popup-inner').css('border-radius', '13px')
</script>
<?php endif; ?>



<script>
  $(function(){
    $('.subsc').click(function(){
      // $.get("<?php echo url('index/clearusersession'); ?>", function(data){
      //   if(data.code == 1){
      //     window.location.href = "http://mp.weixin.qq.com/s/-AzpDTU7eAD24-R5QUP0wg"
      //   }
      // })
      //cookie('goodsmodel_id', $model_id);
      <?php switch(cookie('goodsmodel_id')): case "1":case "2":case "21":case "22":case "3": ?>
            mui.alert("<img src=<?php echo get_cover(config('frankserviceimg'), 'path'); ?> style='width:100%;'>", '长按扫二维码');
        <?php break; endswitch; if(!(empty($contact_qc) || ($contact_qc instanceof \think\Collection && $contact_qc->isEmpty()))): ?>
            mui.alert('<img src="<?php echo $contact_qc; ?>" style="width:100%;">', '长按扫二维码');
      <?php endif; ?>
    })


    $('.endlimit').each(function(){
      var $this = $(this);
      var stime = $this.attr('data-endtime');
      var starttime = new Date(stime.replace(/-/g,"/"))
      setInterval(function () {
        var nowtime = new Date();
        var time = starttime - nowtime;
        if(time > 0){
          var day = parseInt(time / 1000 / 60 / 60 / 24);
          var hour = parseInt(time / 1000 / 60 / 60 % 24);
          var minute = parseInt(time / 1000 / 60 % 60);
          var seconds = parseInt(time / 1000 % 60);
          $this.html("距结束还有:<span style='color:red'>"+ day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒</span>");
        }

      }, 1000);
    })

    $('.hidecartbtn').each(function(){
      var id = $(this).attr('data-id')
      $('.cartbtn'+id).hide();
    })


  })
</script>

 

 <!-- <?php if(empty(\think\Cookie::get('positioninit')) || (\think\Cookie::get('positioninit') instanceof \think\Collection && \think\Cookie::get('positioninit')->isEmpty())): ?>
 <script type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js"></script>
 <script>
   $(function(){
    var geolocation = new qq.maps.Geolocation("QQ6BZ-24HC6-ZAXSZ-MTZAU-5MU2J-HEFEH", "鲜果屋");
     geolocation.getIpLocation(showPosition, showErr)

   })

   function showPosition(position) {
     console.log(1111);
     $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'positioninit', 'val': position.lat+','+position.lng}, function(json, textStatus) {});
  };
   function showErr() {
     console.log('定位失败');
   };
 </script>
 <?php endif; ?> -->

</body>
</html>
